home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / 32BIT.DMO < prev    next >
Text File  |  1996-07-04  |  4KB  |  81 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  5.  │  │ FILE NAME   32BIT   .DMO ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16.  
  17. Using 32bit pointers are just like addressing a "Thank you" note to Grandma
  18. with 2 exceptions:  1) 32bit pointers are shorter and easier!
  19.                     2) You ain't'a'gonna' get no birthday goodies from RAM!
  20.  
  21. So, if you've never used pointers or DEF SEG in your life, now's the time
  22. to start because it has NEVER been easier to directly access memory and the
  23. speed and versatility are simply <<AWESOME>>!
  24.  
  25. Here's what you need to know:
  26.  
  27. * 32bit pointers are just BIG numbers and can be added to, subtracted from,
  28.   and passed around just like the DWORD they really are. They are NOT some
  29.   mysterious mumbo-jumbo no matter what the assembly and C programmers would
  30.   like you to think!
  31.  
  32. * Even though you can shoot yourself in the foot (metaphorically speaking)
  33.   with 32bit pointers you could do that with DEF SEG for years and I've
  34.   been loading the wrong values into variables since my Commodore 64 was
  35.   just a pile of California sand! There is no less nor no more guarantee
  36.   when using pointers so the playing field is level and there never were
  37.   any blanks in the gun!
  38.  
  39. * In fact, as 32bit pointers can save groups of code and typing so there
  40.   just may be an argument that using pointers reduces bugs, undocumented
  41.   features, and bugs. (Maybe we could get a $5B grant to study it.)
  42.  
  43. * When you DIM a PTR you can access the data at that address IMMEDIATELY
  44.   for both read and write! No fuss, no muss, just clean code. In fact you
  45.   can get really important data into/out of your machine's RAM that will
  46.   make your life easier. (Like the status of the <INS> key and others.)
  47.  
  48. * Finally and most importantly, when some technosnob starts jumping on your
  49.   case about programming in !BASIC! you can blow his little mind. (Not that
  50.   I've not been doing that for years with PowerBASIC but it's getting easier
  51.   and easier.) In fact, my favorite expressions, often heard, are:
  52.   "You wrote THIS in BASIC?" and "You can't do that in BASIC!".
  53.  
  54. Below is your playground go get to it! Then, when you're ready have a look
  55. at the next file "32BITPTR.DMO" and we should be ready.
  56.  
  57. $endif
  58.  
  59. COLOR 7, 0
  60. CLS
  61.  
  62. X% = 258
  63. DIM X_ptr AS INTEGER PTR
  64. DIM H_ptr AS BYTE    PTR
  65. DIM L_ptr AS BYTE    PTR
  66.  
  67. X_ptr = VARPTR32( X% )
  68. H_ptr = X_ptr
  69. L_ptr = X_ptr + 1
  70.  
  71. PRINT @X_ptr
  72. PRINT @H_ptr
  73. PRINT @L_ptr
  74. PRINT
  75.  
  76. @X_ptr = &hFFFF
  77.  
  78. PRINT @X_ptr
  79. PRINT @H_ptr
  80. PRINT @L_ptr
  81.